named arguments


C# : http://msdn.microsoft.com/en-us/library/dd264739.aspx
When you use named and optional arguments, the arguments are evaluated in the order in which they appear in the argument list, not the parameter list.
A named argument can follow positional arguments, as shown here : CalculateBMI(123, height: 64);
However, a positional argument cannot follow a named argument : //CalculateBMI(weight: 123, 64);

Python
http://docs.python.org/py3k/reference/compound_stmts.html#function-definitions
http://docs.python.org/py3k/reference/expressions.html#calls
http://docs.python.org/tutorial/controlflow.html#more-on-defining-functions
http://docs.python.org/extending/extending.html#keyword-parameters-for-extension-functions



=================================================================
--> I started to think about that, but it appears that the ooRexx arguments are not easy to manage by name.
It's because the arguments are not declared in a single place at the begining of a procedure/routine/method.
They can be declared several times, and complex expressions can be used (stem, instance's attribute, ...).
Moreover, named arguments can be passed in any order, and that's a problem with current management by array.
So, I give up...
[2015 mar 8]
I reopen the subject... Named arguments can be managed separately from the array of arguments.
"123 456 789"~reduceW(100, "+")
could become
"123 456 789"~reduce("+") by:"word" initial:100
The named parameters don't impact the array of arguments, nor the declaration of arguments.
They could be provided in a directory returned by .context~namedArgs.
They could be optionally be declared with the 'use' instruction :
use strict named args by, initial=.nil


24/11/2018
Named arguments are implemented.

==================================================================
28/02/2020
old implementation
Internally, the named arguments are passed as an array appended to the array of
positional arguments. The count of named arguments is inserted between the two
arrays.       +----+----+----+---+----+----+----+----+
              | P1 | P2 | P3 | 2 | N1 | V1 | N2 | V2 |
              +----+----+----+---+----+----+----+----+
                               |
                             count

new implementation
The count of named arguments is passed with an additional C++ parameter.
count=3, named_count=2
              +----+----+----+----+----+----+----+
              | P1 | P2 | P3 | N1 | V1 | N2 | V2 |
              +----+----+----+----+----+----+----+
This reduces the need to make intermediate copies.

Simplification to pass named arguments to natives functions.
Before:
    The named arguments were passed to the C++ method as 2 C++ parameters per named argument.
        native_cpp_method(P1, P2, P3, N1, V1, N2, V2)
    The order was the order used by the caller to pass the named arguments.
    That was acceptable when only one named argument is expected, but not a good approach for a general support.
    Moreover, CPPCode::run had to support many cases to pass the C++ arguments.
Now:
    The named arguments are passed as an array: ptr and count.
        native_cpp_method(P1, P2, P3, array_ptr, array_count)
    CPPCode::run has only two cases to support : with or without name arguments.
    The callee can use the helper NamedArguments.check to collect the named arguments in a useful order.
Later ?
    The helper NamedArguments.check could be run from CPPCode::run if I can find a way to associate the
    description of the named arguments to CPPCode.
    That would allow to pass only the values of named arguments, without their names, because the order
    would be the order used by the callee to declare the expected named arguments.
        native_cpp_method(P1, P2, P3, V1, V2)


Setup.cpp
search declarations of named arguments
\)[[:blank:]]*,[[:blank:]]*[[:digit:]]+[[:blank:]]*,[[:blank:]]*[[:digit:]]+[[:blank:]]*\)

  defineKernelMethod("STARTWITH"                 ,TheObjectBehaviour, CPPM(RexxObject::startWith), 2,1); // support named arguments
  defineKernelMethod("SENDWITH"                  ,TheObjectBehaviour, CPPM(RexxObject::sendWith), 2, 1); // support named arguments
  defineKernelMethod(CHAR_UNKNOWN       , TheDirectoryBehaviour, CPPM(RexxObject::unknownRexx), 2, 1); // support named arguments
  defineKernelMethod(CHAR_CALLWITH     ,TheRoutineBehaviour, CPPM(RoutineClass::callWithRexx), 1, 1); // support named arguments
  defineKernelMethod(CHAR_SETARGS       ,TheRexxContextBehaviour, CPPM(RexxContext::setArgs), 1, 1); // support named arguments
  defineKernelMethod(CHAR_UNKNOWN       ,TheStemBehaviour, CPPM(RexxObject::unknownRexx), 2, 1); // support named arguments
  defineKernelMethod(CHAR_UNKNOWN                      ,TheIntegerBehaviour, CPPM(RexxObject::unknownRexx), 2, 1); // support named arguments
  defineKernelMethod(CHAR_UNKNOWN                      ,TheNumberStringBehaviour, CPPM(RexxObject::unknownRexx), 2, 1); // support named arguments
